<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>将提供的源码按 PHP 标记进行分割</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.token-get-all" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">token_get_all</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">token_get_all</span> &mdash; <span class="dc-title">将提供的源码按 PHP 标记进行分割</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.token-get-all-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>token_get_all</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$source</code></span>
   ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>token_get_all()</strong></span> 解析提供的 <code class="parameter">source</code> 
   源码字符，然后使用 Zend 引擎的语法分析器获取源码中的 PHP 语言的解析器代号
  </p>
  <p class="para">
   解析器代号列表见<a href="tokens.html" class="xref">解析器代号列表</a>, 或者使用 
   <span class="function"><a href="token_name.html" class="function">token_name()</a></span> 翻译获取这个代号的字符串表示.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.token-get-all-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">source</code></dt>

     <dd>

      <p class="para">
       需要解析的 PHP 源码.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.token-get-all-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   An array of token identifiers. Each individual token identifier is either
   a single character (i.e.: <em>;</em>, <em>.</em>, 
   or a three element array containing the token index in element 0, the string
   content of the original token in element 1 and the line number in element 2.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.token-get-all-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4879">
    <p><strong>Example #1 <span class="function"><strong>token_get_all()</strong></span> examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$tokens&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">token_get_all</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;?php&nbsp;echo;&nbsp;?&gt;'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">/*&nbsp;=&gt;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(T_OPEN_TAG,&nbsp;'&lt;?php'),&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(T_ECHO,&nbsp;'echo'),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';',<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array(T_CLOSE_TAG,&nbsp;'?&gt;')&nbsp;);&nbsp;*/<br /><br />/*&nbsp;Note&nbsp;in&nbsp;the&nbsp;following&nbsp;example&nbsp;that&nbsp;the&nbsp;string&nbsp;is&nbsp;parsed&nbsp;as&nbsp;T_INLINE_HTML<br />&nbsp;&nbsp;&nbsp;rather&nbsp;than&nbsp;the&nbsp;otherwise&nbsp;expected&nbsp;T_COMMENT&nbsp;(T_ML_COMMENT&nbsp;in&nbsp;PHP&nbsp;&lt;5).<br />&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;because&nbsp;no&nbsp;open/close&nbsp;tags&nbsp;were&nbsp;used&nbsp;in&nbsp;the&nbsp;"code"&nbsp;provided.<br />&nbsp;&nbsp;&nbsp;This&nbsp;would&nbsp;be&nbsp;equivalent&nbsp;to&nbsp;putting&nbsp;a&nbsp;comment&nbsp;outside&nbsp;of&nbsp;&lt;?php&nbsp;?&gt;&nbsp;tags&nbsp;in&nbsp;a&nbsp;normal&nbsp;file.&nbsp;*/<br /></span><span style="color: #0000BB">$tokens&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">token_get_all</span><span style="color: #007700">(</span><span style="color: #DD0000">'/*&nbsp;comment&nbsp;*/'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;=&gt;&nbsp;array(array(T_INLINE_HTML,&nbsp;'/*&nbsp;comment&nbsp;*/'));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.token-get-all-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.2.2</td>
       <td>Line numbers are returned in element 2
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

</div></div></div></body></html>